#include <iostream>
#include <cstdio>

#define MAXN 100010

using namespace std;

int s[MAXN] = {0};

int main(){
    int tmp, n, m;
    cin >> n;
    for(int i = 1; i <= n; i++){
        scanf("%d", &tmp);
        s[i] = s[i-1] + tmp;
    }
    cin >> m;
    int l, r;
    for(int i = 1; i <= m; i++){
        scanf("%d%d", &l, &r);
        printf("%d\n", s[r] - s[l-1]);
    }
    return 0;
}